#pragma once

namespace ne{
enum ECollisionType{
	CT_NONE = 0,
	CT_GAME_OBJECT
};

class IComponentCollision;
class GameObject;
struct CollisionData{
	CollisionData(int type):m_type(type){}
	int m_type;
};
struct GameObjectCollisionData:CollisionData{
	GameObjectCollisionData(void):CollisionData(CT_NONE),m_gameObject(nullptr),m_owner(nullptr){}
	GameObjectCollisionData(GameObject* gameObject,IComponentCollision* owner):
	CollisionData(CT_GAME_OBJECT),m_gameObject(gameObject),m_owner(owner){}
	GameObject* m_gameObject;
	IComponentCollision* m_owner;
};
typedef std::vector<std::pair<const btCollisionObject*,const btCollisionObject*>> CollisionList;

struct CObjContainer{
	CObjContainer(btCollisionObject* object):m_object(object){}
	btCollisionObject* m_object;
};

class IgnoreObjectCast : public btCollisionWorld::ClosestRayResultCallback{
public:
	IgnoreObjectCast(const CObjContainer& objContainer):btCollisionWorld::ClosestRayResultCallback(btVector3(0,0,0), btVector3(0,0,0)),
		m_objContainer(objContainer){}
	~IgnoreObjectCast(void){}
	btScalar addSingleResult(btCollisionWorld::LocalRayResult& ray_result,bool normal_in_world_space){
		if (ray_result.m_collisionObject==m_objContainer.m_object){
			return 1.0f;
		}
		return ClosestRayResultCallback::addSingleResult(ray_result,normal_in_world_space);
	}
	GameObject* GetGameObject(){
		return static_cast<GameObjectCollisionData*>(m_collisionObject->getUserPointer())->m_gameObject;
	}
	Ogre::Vector3 GetHitPointWorld(){return Convert::ToOgre(m_hitPointWorld);}
	Ogre::Vector3 GetHitNormalWorld(){return Convert::ToOgre(m_hitNormalWorld);}
	bool HasHit(){return hasHit();}


protected:
	CObjContainer m_objContainer;
};
}